/**
 * 
 */
package com.axt.dbaudit.action.cfg;

import java.util.*;
import com.axt.dbaudit.bean.cfg.AlertCfgBean;
import com.axt.dbaudit.model.cfg.AlertCfg;
import com.axt.soa.msg.types.MsgParam;
import com.axt.soa.action.*;
import org.apache.struts2.json.annotations.JSON;

public class AlertCfgAction extends BaseAction {
	AlertCfgBean alertCfgBean = new AlertCfgBean();
	List<AlertCfg> alertCfgs = new ArrayList<AlertCfg>();
	
	private int au_isEnableEmailAlert;
	private int au_eHighRisk;
	private int au_eMiddleRisk;
	private int au_eLowRisk;
	private int au_alertInterval;
	private int au_isEnableBubbleAlert;
	private int au_bHighRisk;
	private int au_bMiddleRisk;
	private int au_bLowRisk;
	private int au_isEnableSoundAlert;
	private String au_FilePath;
	
	/**
	 * @return the au_isEnableEmailAlert
	 */
	public int getAu_isEnableEmailAlert() {
		return au_isEnableEmailAlert;
	}
	/**
	 * @param au_isEnableEmailAlert the au_isEnableEmailAlert to set
	 */
	public void setAu_isEnableEmailAlert(int au_isEnableEmailAlert) {
		this.au_isEnableEmailAlert = au_isEnableEmailAlert;
	}
	/**
	 * @return the au_eHighRisk
	 */
	public int getAu_eHighRisk() {
		return au_eHighRisk;
	}
	/**
	 * @param au_eHighRisk the au_eHighRisk to set
	 */
	public void setAu_eHighRisk(int au_eHighRisk) {
		this.au_eHighRisk = au_eHighRisk;
	}
	/**
	 * @return the au_eMiddleRisk
	 */
	public int getAu_eMiddleRisk() {
		return au_eMiddleRisk;
	}
	/**
	 * @param au_eMiddleRisk the au_eMiddleRisk to set
	 */
	public void setAu_eMiddleRisk(int au_eMiddleRisk) {
		this.au_eMiddleRisk = au_eMiddleRisk;
	}
	/**
	 * @return the au_eLowRisk
	 */
	public int getAu_eLowRisk() {
		return au_eLowRisk;
	}
	/**
	 * @param au_eLowRisk the au_eLowRisk to set
	 */
	public void setAu_eLowRisk(int au_eLowRisk) {
		this.au_eLowRisk = au_eLowRisk;
	}
	/**
	 * @return the au_alertInterval
	 */
	public int getAu_alertInterval() {
		return au_alertInterval;
	}
	/**
	 * @param au_alertInterval the au_alertInterval to set
	 */
	public void setAu_alertInterval(int au_alertInterval) {
		this.au_alertInterval = au_alertInterval;
	}
	/**
	 * @return the au_isEnableBubbleAlert
	 */
	public int getAu_isEnableBubbleAlert() {
		return au_isEnableBubbleAlert;
	}
	/**
	 * @param au_isEnableBubbleAlert the au_isEnableBubbleAlert to set
	 */
	public void setAu_isEnableBubbleAlert(int au_isEnableBubbleAlert) {
		this.au_isEnableBubbleAlert = au_isEnableBubbleAlert;
	}
	/**
	 * @return the au_bHighRisk
	 */
	public int getAu_bHighRisk() {
		return au_bHighRisk;
	}
	/**
	 * @param au_bHighRisk the au_bHighRisk to set
	 */
	public void setAu_bHighRisk(int au_bHighRisk) {
		this.au_bHighRisk = au_bHighRisk;
	}
	/**
	 * @return the au_bMiddleRisk
	 */
	public int getAu_bMiddleRisk() {
		return au_bMiddleRisk;
	}
	/**
	 * @param au_bMiddleRisk the au_bMiddleRisk to set
	 */
	public void setAu_bMiddleRisk(int au_bMiddleRisk) {
		this.au_bMiddleRisk = au_bMiddleRisk;
	}
	/**
	 * @return the au_bLowRisk
	 */
	public int getAu_bLowRisk() {
		return au_bLowRisk;
	}
	/**
	 * @param au_bLowRisk the au_bLowRisk to set
	 */
	public void setAu_bLowRisk(int au_bLowRisk) {
		this.au_bLowRisk = au_bLowRisk;
	}
	/**
	 * @return the au_isEnableSoundAlert
	 */
	public int getAu_isEnableSoundAlert() {
		return au_isEnableSoundAlert;
	}
	/**
	 * @param au_isEnableSoundAlert the au_isEnableSoundAlert to set
	 */
	public void setAu_isEnableSoundAlert(int au_isEnableSoundAlert) {
		this.au_isEnableSoundAlert = au_isEnableSoundAlert;
	}
	/**
	 * @return the au_FilePath
	 */
	public String getAu_FilePath() {
		return au_FilePath;
	}
	/**
	 * @param au_FilePath the au_FilePath to set
	 */
	public void setAu_FilePath(String au_FilePath) {
		this.au_FilePath = au_FilePath;
	}
	
	@JSON(name="alertCfgs")
	public List<AlertCfg> getAlertCfgs() {
		return alertCfgs;
	}
	public void setAlertCfgs(List<AlertCfg> alertCfgs) {
		this.alertCfgs = alertCfgs;
	}
	
	@JSON(name="errcode")
	public int getErrcode() {
		return errcode;
	}
	
	@JSON(name="errinfo")
	public String getErrinfo() {
		return errinfo;
	}
	
	/**
	 * 获取报警方式配置
	 */
	public String queryAlertCfg()
	{
		setAlertCfgs(alertCfgBean.queryAlertCfg(serverPath));
		setErrcode(alertCfgBean.getErrcode());
		setErrinfo(alertCfgBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	/**
	 * 更新报警方式配置
	 */
	public String updateAlertCfg()
	{
		AlertCfg alertCfg = new AlertCfg();
		alertCfg.setAu_isEnableBubbleAlert(au_isEnableEmailAlert);
		alertCfg.setAu_eHighRisk(au_eHighRisk);
		alertCfg.setAu_eMiddleRisk(au_eMiddleRisk);
		alertCfg.setAu_eLowRisk(au_eLowRisk);
		alertCfg.setAu_alertInterval(au_alertInterval);
		alertCfg.setAu_isEnableBubbleAlert(au_isEnableBubbleAlert);
		alertCfg.setAu_bHighRisk(au_bHighRisk);
		alertCfg.setAu_bMiddleRisk(au_bMiddleRisk);
		alertCfg.setAu_bLowRisk(au_bLowRisk);
		alertCfg.setAu_isEnableSoundAlert(au_isEnableSoundAlert);
		alertCfg.setAu_FilePath(au_FilePath);
		
		alertCfgBean.updateAlertCfg(serverPath, alertCfg);
		setErrcode(alertCfgBean.getErrcode());
		setErrinfo(alertCfgBean.getErrinfo());
		
		return MsgParam.SUCCESS;	
	}
}
